import * as types from './actionTypes';
import { fromJS } from 'immutable';
const defaultState = fromJS({
    focus: false,
    list: [],
    mouseIn: false,
    page: 1,
    totalPage: 1
});

export default (state = defaultState, action) => {

    switch(action.type) {
        case types.HANDLE_INPUT_FOCUS:
            return state.setIn(['focus'], true);
        case types.HANDLE_INPUT_BLUR:
            return state.setIn(['focus'], false);
        case types.MOUSE_ENTER_IN:
            return state.setIn(['mouseIn'],true);
        case types.MOUSE_LEAVE:
            return state.setIn(['mouseIn'],false);
        case types.GET_HEADER_LIST:
            return state.merge({
                list: action.data,
                totalPage: action.totalPage
            });
        case types.HANDLE_PAGE:
            return state.setIn(['page'],action.page);
        default :return state;
    }
};